package com.shujia.indicators.utils;

import org.apache.spark.sql.SparkSession;

public class SparkUtils {
    private static ThreadLocal<SparkSession> sessionPool = new ThreadLocal();

    public static SparkSession initSession(){
        if(sessionPool.get() != null){
            return sessionPool.get();
        }
        SparkSession session = SparkSession.builder()
                .appName("userportraits")
                .master("local[*]")
                .enableHiveSupport()
                .getOrCreate();

        sessionPool.set(session);
        return session;
    }
}
